Skip to content

Data tracks support#586

Draft
ladvoc wants to merge 18 commits intomainfrom
jacobgelman/bot-242-python-client-implementation
Draft

Data tracks support#586
ladvoc wants to merge 18 commits intomainfrom
jacobgelman/bot-242-python-client-implementation

Conversation

@ladvoc
Copy link
Contributor

@ladvoc ladvoc commented Mar 5, 2026

No description provided.

@pblazej
Copy link

pblazej commented Mar 16, 2026

Some things from talking to claude (maybe you find it useful):

  • SubscribeDataTrackError / PublishDataTrackError not exported
  • existing streams use aclose() (async), while DataTrackSubscription uses close() (sync); all of them can probably leverage https://www.geeksforgeeks.org/python/aenter-in-python/
  • no remote_data_track_unpublished event - just mirroring rust comment here
  • try_push should probably be push in python
  • remote_data_track_published should be data_track_published as other tracks
  • DataTrackFrame(payload=...) may validate the input type (what happens if you pass a string etc.)

"""Identity of the participant who published the track."""
return self._publisher_identity

async def subscribe(self) -> DataTrackSubscription:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: The python implementation doesn't support the rust equivalent of .subscribe_with_options(DataTrackSubscribeOptions::new().with_buffer_size(64)) - add buffer size support in!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add the equivalent here once it is exposed in the FFI layer.

Comment on lines +270 to +274
async def __anext__(self) -> DataTrackFrame:
if self._closed:
raise StopAsyncIteration

event: proto_ffi.FfiEvent = await self._queue.get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Should the python implementation of data tracks be updated to have the synchronous track.subscribe() behavior which was implemented in javascript, with any subscription errors cascading down into the first iterator __anext__ call?

Comment on lines +304 to +305
def __del__(self) -> None:
self._close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Should this be calling self._close() or self.close()? I think potentially the latter is needed here because otherwise the self._ffi_handle is never cleaned up.

Comment on lines +85 to +87
class PublishDataTrackError(Exception):
def __init__(self, message: str) -> None:
self.message = message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is it worth exposing a more rich set of errors here instead of just the single error with the message, like rust / js have added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants